/**
 * Copyright (c) 2006 RiseSoft Co.,Ltd  
 * $Header$
 */
package net.risesoft.risebi.collection.web;

import com.opensymphony.xwork2.ActionSupport;
import javax.servlet.ServletContext;
import javax.servlet.http.*;
import net.risesoft.risebi.collection.model.*;
import net.risesoft.risebi.collection.service.UserManager;
import net.risesoft.risebi.commons.util.ContextUtil;
import org.apache.struts2.ServletActionContext;
import org.springframework.context.ApplicationContext;

/**
 * 
 * @author <a href="mailto: chenjian@risesoft.net">陈健</a>
 * @version $Revision$
 * 
 */
public class BaseAction extends ActionSupport {


    public BaseAction()
    {
        json = "[]";
    }

    public String getDir()
    {
        return dir;
    }

    public void setDir(String dir)
    {
        this.dir = dir;
    }

    public String getSort()
    {
        return sort;
    }

    public void setSort(String sort)
    {
        this.sort = sort;
    }

    public Boolean getAjaxable()
    {
        return ajaxable;
    }

    public void setAjaxable(Boolean ajaxable)
    {
        this.ajaxable = ajaxable;
    }

    public String getDynaMethod()
    {
        return dynaMethod;
    }

    public void setDynaMethod(String dynaMethod)
    {
        this.dynaMethod = dynaMethod;
    }

    public String getNodeInstance()
    {
        return nodeInstance;
    }

    public void setNodeInstance(String nodeInstance)
    {
        this.nodeInstance = nodeInstance;
    }

    public String getInputName()
    {
        return inputName;
    }

    public void setInputName(String inputName)
    {
        this.inputName = inputName;
    }

    public String getForwardUrl()
    {
        return forwardUrl;
    }

    public void setForwardUrl(String forwardUrl)
    {
        this.forwardUrl = forwardUrl;
    }

    public String getMethod()
    {
        return method;
    }

    public void setMethod(String method)
    {
        this.method = method;
    }

    public int getLimit()
    {
        return limit;
    }

    public void setLimit(int limit)
    {
        this.limit = limit;
    }

    public int getStart()
    {
        return start;
    }

    public void setStart(int start)
    {
        this.start = start;
    }

    public String getAddedTreeNodeJson()
    {
        return addedTreeNodeJson;
    }

    public void setAddedTreeNodeJson(String addedTreeNodeJson)
    {
        this.addedTreeNodeJson = addedTreeNodeJson;
    }

    public String getSource()
    {
        return source;
    }

    public void setSource(String source)
    {
        this.source = source;
    }

    public String getToolbarId()
    {
        return toolbarId;
    }

    public void setToolbarId(String toolbarId)
    {
        this.toolbarId = toolbarId;
    }

    public String getNode()
    {
        return node;
    }

    public void setNode(String node)
    {
        this.node = node;
    }

    public String getPageId()
    {
        return pageId;
    }

    public void setPageId(String pageId)
    {
        this.pageId = pageId;
    }

    public String getEditedName()
    {
        return editedName;
    }

    public void setEditedName(String editedName)
    {
        this.editedName = editedName;
    }

    public String getContextPath()
    {
        HttpServletRequest request = ServletActionContext.getRequest();
        return request.getContextPath();
    }

    public String getRealPath()
    {
        return ServletActionContext.getServletContext().getRealPath("/");
    }

    public HttpServletRequest getRequest()
    {
        return ServletActionContext.getRequest();
    }

    public HttpServletResponse getResponse()
    {
        return ServletActionContext.getResponse();
    }

    public HttpSession getSession()
    {
        return getRequest().getSession();
    }

    public ServletContext getServletContext()
    {
        return ServletActionContext.getServletContext();
    }

    public String getRealyPath(String path)
    {
        return getServletContext().getRealPath(path);
    }

    public String getContextmenuId()
    {
        return contextmenuId;
    }

    public void setContextmenuId(String contextmenuId)
    {
        this.contextmenuId = contextmenuId;
    }

    public String getActive_node_type()
    {
        return active_node_type;
    }

    public void setActive_node_type(String active_node_type)
    {
        this.active_node_type = active_node_type;
    }

    public String getActive_node_id()
    {
        return active_node_id;
    }

    public void setActive_node_id(String active_node_id)
    {
        this.active_node_id = active_node_id;
    }

    public String getWhichJson()
    {
        return whichJson;
    }

    public void setWhichJson(String whichJson)
    {
        this.whichJson = whichJson;
    }

    public String getJson()
    {
        return json;
    }

    public void setJson(String json)
    {
        this.json = json;
    }

    public User getSessionUser()
        throws Exception
    {
        HttpServletRequest request = ServletActionContext.getRequest();
        UserManager userManager = (UserManager)ContextUtil.getAc().getBean("userManager");
        User user = userManager.getUser(request);
        return user;
    }

    public Service getDefaultService()
        throws Exception
    {
        User user = getSessionUser();
        return user.getDefaultService();
    }

    public Application getDefaultApp()
        throws Exception
    {
        User user = getSessionUser();
        return user.getDefaultApp();
    }

    private static final long serialVersionUID = 7940888087187406232L;
    public static final String INDEX = "index";
    public static final String PREPAREADD = "prepareAdd";
    public static final String ADD = "add";
    public static final String PREPAREEDIT = "prepareEdit";
    public static final String EDIT = "edit";
    public static final String REMOVE = "remove";
    public static final String VIEW = "view";
    public static final String LIST = "list";
    public static final String VALIDATE = "validate";
    public static final String VALIDATEFIELD = "validatefField";
    public static final String UPLOAD = "upload";
    public static final String DOWNLOAD = "download";
    public static final String PRINT = "print";
    public static final String AJAX = "ajax";
    public static final String TRANSFER = "transfer";
    public String jsonString;
    protected String json;
    protected String whichJson;
    protected String active_node_id;
    protected String active_node_type;
    protected String pageId;
    protected String toolbarId;
    protected String contextmenuId;
    protected String source;
    protected String node;
    protected String addedTreeNodeJson;
    protected int start;
    protected int limit;
    protected String forwardUrl;
    protected String method;
    protected String editedName;
    protected String inputName;
    protected String nodeInstance;
    protected String dynaMethod;
    protected Boolean ajaxable;
    protected String sort;
    protected String dir;

}
